package com.neepu.controller;


import com.neepu.pojo.User;
import com.neepu.util.annotation.BeforeLog;
import com.neepu.util.common.Constants;
import com.neepu.util.common.SessionSave;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
public class ExitController {
    @BeforeLog(operteContent = "退出系统")
    @RequestMapping(value="/exit")
    public ModelAndView Exit(ModelAndView mv, HttpSession session) {
        mv.setViewName("forward:/loginForm");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        System.out.println("退出系统时间："+df.format(new Date()));
        User user = (User) session.getAttribute(Constants.USER_SESSION);
        SessionSave.getSessionIdSave().remove(user.getUserID());
        session.invalidate();
        return mv;
    }
}


